function [ ] = plotStepFuncMACs(ctrS, graphTab, IncludeCurve, filename, titlestring, optfig)

clearing_price = ctrS.output_itk.Pt(ctrS.idx_out_tk,:);
clearing_price = clearing_price(1);

f0 = figure;

set(gca, optfig.labProp{:}, ...
         'Box'         , 'off'             , ...
         'LineWidth'   , optfig.axisweight);

scatter(ctrS.output_itk.E_noabate(ctrS.idx_out_tk), ...
    ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk), 2, "blue");
hold on
scatter(ctrS.output_itk.E_abate(ctrS.idx_out_tk), ...
    ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk), 2, "cyan");
plot([ctrS.output_itk.E_abate(ctrS.idx_out_tk)';...
    ctrS.output_itk.E_noabate(ctrS.idx_out_tk)'],...
    [ ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk)';...
    ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk)'], ...
    'Color',[0, 0, 0, 0.1]);
plot([ctrS.output_itk.E_noabate(ctrS.idx_out_tk)';...
    ctrS.output_itk.E_noabate(ctrS.idx_out_tk)'],...
    [ zeros(length(ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk)),1)';...
    ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk)'], ...
    'Color',[0, 0, 0, 0.1]);
plot([ctrS.output_itk.E_abate(ctrS.idx_out_tk)';...
    ctrS.output_itk.E_abate(ctrS.idx_out_tk)'],...
    [ zeros(length(ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk)),1)'+100;...
    ctrS.output_itk.pp_avg_p(ctrS.idx_out_tk)'], ...
    'Color',[0, 0, 0, 0.1]);
yline(clearing_price, "red");
xline(ctrS.level, "red");

set(gca, 'XScale', 'log');

xlabel("Emissions",optfig.textProp{:})
ylabel("MAC",optfig.textProp{:})
title(titlestring,optfig.textProp{:},'Interpreter','latex');
%ylim([0 11])

if IncludeCurve
    groups = unique(graphTab.id_pp);
    numGroups = numel(groups);
    for i = 1:numGroups
        groupData = graphTab(graphTab.id_pp == groups(i), :);
        plot(exp(groupData.logE), exp(groupData.predictLogMAC), '-', ...
            'Color',[0, 0, 0, 0.07]);
    end
    ylim([0,55])
end


hold off

fig = gcf;
fig.PaperPositionMode = 'auto';
fig.PaperSize = [8 7];
fig.PaperPosition = [0 0 8 7];

print(f0,'-dpdf','-painters','-noui','-r600', filename)

end